package com.radar.io.radar346.DataType;

import com.radar.io.radar346.Product382改;
import com.radar.utils.BitConverter;

public class VADParse {
    Product382改 _this;

    public VADParse(Product382改 product382改) {
        _this = product382改;
    }

    public void parse(byte[] bytes, int index, Product382改.RealFile header) throws Exception {
        int Layers = header.realObserSec.iLiTiSaoMiaoCengShu;
        int[] Records = new int[Layers];
        double[] MaxV = new double[Layers];
        int Bins = 0;
        for (int i = 0; i < Layers; i++) {
            Records[i] = header.realObserSec.LayerParam[i].iCaiYangJinXiangShu;
            _this.Bins = header.realObserSec.LayerParam[i].usRefBinNumber;
        }
        _this.azi = new double[Records[0]];  //长度为每层径向数
        _this.vad = new VAD();
        _this.vad.速度方位显示所分析的仰角 = BitConverter.toFloat(bytes, index);   //
        index += 4;
        _this.vad.速度方位显示所分析的水平距离 = BitConverter.toFloat(bytes, index);   //
        index += 4;
        _this.vad.速度方位显示所分析的径向距离 = BitConverter.toFloat(bytes, index);
        index += 4;
        _this.vad.速度方位显示所分析的垂直距离 = BitConverter.toFloat(bytes, index);
        index += 4;
        _this.vad.拟合速度曲线的对称性 = BitConverter.toFloat(bytes, index);
        index += 4;
        _this.vad.分析区域的平均风速 = BitConverter.toFloat(bytes, index);
        index += 4;
        _this.vad.分析区域的平均风向 = BitConverter.toFloat(bytes, index);
        index += 4;
        _this.vad.拟合速度的均方根误差 = BitConverter.toFloat(bytes, index);
        index += 4;
        _this.vad.PPI所包含的径向个数 = BitConverter.toFloat(bytes, index);
        index += 4;
        _this.vad.最小速度 = BitConverter.toFloat(bytes, index);
        index += 4;
        _this.vad.最大速度 = BitConverter.toFloat(bytes, index);
        index += 4;
        // TODO 数据错误
        _this.vad.强度值 = new float [(int) _this.vad.PPI所包含的径向个数];
        _this.vad.速度值 = new float [(int) _this.vad.PPI所包含的径向个数];
        _this.vad.速度方位值 = new float [(int) _this.vad.PPI所包含的径向个数];
        for (int i = 0 ; i < _this.vad.PPI所包含的径向个数 ; i ++) {
            _this.vad.强度值[i] = BitConverter.toFloat(bytes, index);
            _this.vad.速度值[i] = BitConverter.toFloat(bytes, index + _this.vad.强度值.length * 4);
            _this.vad.速度方位值[i] = BitConverter.toFloat(bytes, index + _this.vad.强度值.length * 8);
            index += 4;
        }
    }
}
